# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName  :send_tasks.py
# @Time      :2022/6/8 0008 19:48
# @Author    :何胜利
import json

from ronglian_sms_sdk import SmsSDK

from common.celery_tasks.main import app


@app.task
def send_code(mobile, code, expiry=5):
    sdk = SmsSDK(
        accId="8a216da8804ba8a5018064a2f6770685",
        accToken="6ee0ec3216db4cc0acfdd3764827fbc2",
        appId="8a216da8804ba8a5018064a2f7fc068c",
    )

    # 组织数据
    tid = "1"
    mobile = "%s" % mobile
    datas = ("%s" % code, "%s" % expiry)

    resp = sdk.sendMessage(tid=tid, mobile=mobile, datas=datas)
    return json.loads(resp)
